package com.yansu.own.common.dtos;

import lombok.Data;

import java.io.Serializable;
import java.util.List;

@Data
public class PageResponseResult extends ResponseResult implements Serializable {
    private Integer currentPage;
    private Integer size;
    private Integer total;

    public PageResponseResult(Integer currentPage, Integer size, Integer total) {
        this.currentPage = currentPage;
        this.size = size;
        this.total = total;
    }

    public PageResponseResult() {

    }

    public static PageResponseResult getPageList(List<?> rows){
        PageResponseResult page = new PageResponseResult();
        page.setCode(200);
        page.setData(rows);
        page.setMsg("查询成功");
        if(rows == null || rows.size() == 0){
            page.setTotal(0);
        }else{
            page.setTotal(rows.size());
        }
        return page;
    }
}
